﻿<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>修改密码-伯乐网</title>
    <link href="style/css/style.css" type="text/css" rel="stylesheet">
    <link href="style/css/external.min.css" type="text/css" rel="stylesheet">
    <link href="style/css/popup.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="style/js/jquery.1.10.1.min.js"></script>
    <script src="style/js/jquery.lib.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="style/js/ajaxfileupload.js"></script>
    <script src="style/js/additional-methods.js" type="text/javascript"></script>
    <!--layer.js-->
    <script type="text/javascript" src="style/js/layer/layer.js"></script>
</head>

<body>
<!--隐藏域存放用户ID-->
<input type="hidden" id="userId" th:value="${session.user.id}">
<div id="body">
    <!--引入顶部导航栏-->
    <div id="header" th:fragment="common_top_nav">
        <div class="wrapper">
            <a href="/index" class="logo">
                <img src="style/images/logo.png" width="229" height="43" alt="伯乐网-专注互联网招聘"/>
            </a>
            <ul class="reset" id="navheader">
                <li >
                    <a href="/index">首页</a>
                </li>
                <li>
                    <a href="/companyList?page=1&size=9&companyName=&city=全国&stage=&field=" style="margin-left: 50px">搜索公司</a>
                </li>
                <li class="current">
                    <a th:href="'/jianli?userId='+${session.user.id}" rel="nofollow" style="margin-left: 50px">我的简历</a>
                </li>
            </ul>
            <!--未登陆显示登陆注册-->
            <ul class="loginTop" th:if="${session.user}==null">
                <li>
                    <a href="/loginPage" rel="nofollow">登录</a>
                </li>
                <li>|</li>
                <li>
                    <a href="/registerPage" rel="nofollow">注册</a>
                </li>
            </ul>
            <!--已经登陆显示下拉列表-->
            <dl class="collapsible_menu" th:if="${session.user}!=null">
                <dt>
                    <span th:text="${session.user.phone}">路人甲</span>
                    <span class="red dn" id="noticeDot-0"></span>
                    <i></i>
                </dt>
                <dd>
                    <a rel="nofollow" th:href="'/jianli?userId='+${session.user.id}">我的简历</a>
                </dd>
                <dd>
                    <a th:href="'/selectCollections?userId='+${session.user.id}">我收藏的职位</a>
                </dd>
                <dd>
                    <a href="javascript:void(0)">我投递的职位 <span id="noticeNo" class="red dn">(0)</span></a>
                </dd>
                <dd>
                    <a href="/setting">帐号设置</a>
                </dd>
                <dd class="logout">
                    <a rel="nofollow" href="/logout">退出</a>
                </dd>
            </dl>

        </div>
    </div>
    <!--顶部导航栏 end-->

    <div id="container">
        <div class="user_bindSidebar">
            <dl id="user_sideBarmenu" class="user_sideBarmenu">
                <dt><h3>帐号设置</h3></dt>
                <dd>
                    <a class="hover" href="/accountSetting">修改密码</a>
                </dd>
            </dl>
        </div>
        <div class="content user_modifyContent">
            <dl class="c_section">
                <dt>
                    <h2><em></em>修改密码</h2>
                </dt>
                <dd>
                    <table class="savePassword">
                        <tbody>
                        <tr>
                            <td>登录账号</td>
                            <td class="c7" id="phone">[[${session.user.phone}]]</td>
                        </tr>
                        <tr>
                            <td class="label">当前密码</td>
                            <td>
                                <input type="password" id="oldPwd" name="oldPwd"
                                       style="background-image: url(style/images/img/0CQnd2Jos49xUAAAAASUVORK5CYII=quot); background-repeat: no-repeat; background-attachment: scroll; background-position: right center;">
            				</span></td>
                        </tr>
                        <tr>
                            <td class="label">新密码</td>
                            <td><input type="password" id="newPwd" name="newPwd"
                                       style="background-image: url(style/images/img/a6y3y0Wx5kbFHvGuXzkgf0xhKnPzA4UTyaTB8Ph8AvcHi3fnsrZ7Wore02YViqVOrRXXPhfqP8j6MYlawoAAAAASUVORK5CYII=quot); background-repeat: no-repeat; background-attachment: scroll; background-position: right center;">
                            </td>
                        </tr>
                        <tr>
                            <td class="label">确认密码</td>
                            <td><input type="password" id="rePwd" name="rePwd"
                                       style="background-image: url(style/images/img/a6y3y0Wx5kbFHvGuXzkgf0xhKnPzA4UTyaTB8Ph8AvcHi3fnsrZ7Wore02YViqVOrRXXPhfqP8j6MYlawoAAAAASUVORK5CYII=quot); background-repeat: no-repeat; background-attachment: scroll; background-position: right center;">
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td><input type="submit" id="updatePwd" value="保 存"></td>
                        </tr>
                        </tbody>
                    </table>
                </dd>
            </dl>
        </div>
        <script>
            //点击保存按钮
            $("#updatePwd").click(function () {
                //获取当前登陆人ID
                var userId = $("#userId").val().trim();
                //获取登陆账号
                var phone = $("#phone").text().trim();
                //获取原密码
                var oldPwd = $("#oldPwd").val().trim();
                //获取新密码
                var newPwd = $("#newPwd").val().trim();
                //获取确认密码
                var rePwd = $("#rePwd").val().trim();
                console.log("登陆人ID：" + userId);
                console.log("获取登陆账号：" + phone);
                console.log("获取原密码：" + oldPwd);
                console.log("获取新密码：" + newPwd);
                console.log("获取确认密码：" + rePwd);
                if (oldPwd == "" || oldPwd == null) {
                    layer.msg("请输入原密码")
                    return false;
                }
                if (oldPwd.length > 16 || oldPwd.length < 6) {
                    layer.msg("原始密码长度应介于6～16位！");
                    return false;
                }

                if (newPwd == "" || newPwd == null) {
                    layer.msg("请输入新密码！");
                    return false;
                }
                if (newPwd.length > 16 || newPwd.length < 6) {
                    layer.msg("新密码长度应介于6～16位！");
                    return false;
                }

                if (rePwd == "" || rePwd == null) {
                    layer.msg("请输入确认密码！");
                    return false;
                }
                if (rePwd.length > 16 || rePwd.length < 6) {
                    layer.msg("确认密码长度应介于6～16位！");
                    return false;
                }
                if (newPwd != rePwd) {
                    layer.msg("新密码与确认密码不一致！");
                    return false;
                }
                //数据校验通过，发送请求
                $.ajax({
                    type: "post",
                    url: "/updatePwd",
                    data: {
                        userId: userId,
                        phone: phone,
                        oldPwd: oldPwd,
                        newPwd: newPwd
                    },
                    success: function (result) {
                        //成功的回调函数
                        if (result.code == 0) {
                            //密码修改成功
                            layer.alert("密码修改成功,请重新登陆", {icon: 1, title: '提示'}, function () {
                                location.href = "/loginPage";
                            });
                            return false;
                        } else if (result.code == -1) {
                            //用户名或密码错误
                            layer.alert("用户名或密码错误！", {icon: 2});
                            return false;
                        } else {
                            layer.alert("系统异常,请稍后再试！", {icon: 5});
                        }
                    }
                });


            });

        </script>
        <script src="style/js/setting.js"></script>
        <div class="clear"></div>
        <input type="hidden" value="" id="resubmitToken">
        <a rel="nofollow" title="回到顶部" id="backtop"></a>
    </div>
    <!-- end #container -->
</div>
<!-- end #body -->
<!--引入页面底部备案号-->
<div th:replace="public/publicFragment::footer_nav"></div>

<script src="style/js/core.min.js" type="text/javascript"></script>
<script src="style/js/popup.min.js" type="text/javascript"></script>

</body>

</html>